<?php

if($this->categories){
    foreach($this->categories as $obj){
?>
<div class="center-box">
    <div class="box-title">
        <div class="wrapper">
            <a class="root" href="<?php echo $this->url($obj->category->getProperties(), 'product_product_category')?>">
                <?php echo $obj->category->name ?>
            </a>
            <ul class="sub-categories">
                <?php if($obj->subCategories){
                    foreach($obj->subCategories as $subCategory){
                ?> 
                <li>
                    <a href="<?php echo $this->url($subCategory->getProperties(), 'product_product_category')?>">
                        <?php echo $subCategory->name?>
                    </a>
                </li>
                <?php
                    }
                }
                ?>
            </ul>
        </div>
    </div>
    <div class="box-container">
        <ul class="jcarousel jcarousel-skin-tango">
            <?php 
            
            if($obj->products){
                foreach($obj->products as $product){
            ?>
            <li>
                <div class="product-thumbnail">
                    <img src="<?php echo $product->image_thumbnail?>" alt="<?php echo $product->name?>"/>
                    <div class="shadow"></div>
                </div>
                <h4>
                    <a href="<?php echo $this->url($product->getProperties(), 'product_product_details')?>">
                        <?php echo $product->name;?>
                    </a>
                </h4>
                <p class="product-price">
                    <span class="label"><?php echo $this->translate()->widget('price')?>:</span>
                    <span class="price"><?php echo number_format($product->price, 0,'.', ',') ?> VNĐ</span>
                </p>
                <div class="product-buttons">
                    <a class="product-details"><?php echo $this->translate()->widget('details')?></a>
                    <a class="product-add-to-cart"><?php echo $this->translate()->widget('add_to_cart')?></a>
                </div>
            </li>
            <?php
                }
            }?>
        </ul>
    </div>
</div><!-- .box-center -->

<?php
    }
}
?>
<script type="text/javascript">
    $(document).ready(function(){
        $('.center-box .jcarousel').each(function(){
            if($(this).children('li').length > 0){
                $(this).jcarousel({
                    animation: 1000,
                    scroll : 3,                        
                    wrap : 'both'
                });
            }
        })
        
    });
</script>